<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<strong><%@ taglib prefix="c"
                   uri="http://java.sun.com/jsp/jstl/core" %></strong>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>艺术家管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/xAdmin/css/font.css">
    <link rel="stylesheet" href="/xAdmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/xAdmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/xAdmin/js/xadmin.js"></script>

    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">艺术家</a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" class="layui-input"  autocomplete="off" placeholder="手机号" name="mobilephono" id="mobilephono">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="name" id="name" placeholder="用户名" autocomplete="off" class="layui-input">
                        </div>
                        <button class="layui-btn" data-type="reload" id="demoTable">搜索</button>
                </div>

                <div class="layui-card-body ">
                    <table class="layui-table" id="idTest" lay-filter="idTest" ></table>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page" id="page">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var userid =null;
    var userdesc=null
    layui.use('table', function(){
        var table = layui.table;
        //第一个实例
        table.render({
            elem: '#idTest'
            ,height: 350
            ,url: '/tBizArt/getUserList' //数据接口
            ,cols: [[ //表头
                {type:'radio',fixed: 'left'}
                ,{field: 'id', title: 'ID', width:80,fixed: true}
                ,{field: 'name', title: '姓名', width:100}
                // ,{field: 'mainpic', title: '图片', width:150,}
                // templet:function(d){
                //     console.log(d.mainpic);
                //         return '<div> <img src="../ajaxData/photoQuery?type=style/ys320&imgPath="+{d.mainpic} /> </div>';
                //     }}
                ,{field: 'mobilephono', title: '手机', width:120, }
                ,{field: 'email', title: '邮箱', width:100}
                ,{field: 'birthday', title: '生日', width: 100}
            ]]
            ,id: 'testReload'
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout:  ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'] //自定义分页布局
                ,curr: 1 //设定初始在第 5 页
                ,groups: 3 //只显示 1 个连续页码
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });

        var $ = layui.$, active = {
            reload: function(){
                var name = $('#name').val();
                var mobilephono = $('#mobilephono').val();

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                            name: name,
                            mobilephono:mobilephono
                    }
                }, 'data');
            }
            // ,
            // getCheckData: function(){ //获取选中数据
            //     data = datas;
            //     userid =data.id;
            //     username= data.name;
            //     console.log( parent.$('#userid').val());
            //     parent.$('#userid').val(userid);
            //     parent.$('#userdesc').val(username);
            //     var index = parent.layer.getFrameIndex(window.name);
            //     parent.layer.close(index);
            //     // layer.alert(JSON.stringify(data));
            // }
        };
        table.on('radio(idTest)', function(obj){
            userid = obj.data.id;
            userdesc = obj.data.name;
        });

        $('#demoTable').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        // $('.demoTable .layui-btn').on('click', function(){
        //     var type = $(this).data('type');
        //     active[type] ? active[type].call(this) : '';
        // });

    });



</script>
</html>
